n, m = map(int,input().split())
l = list(map(int,input().split()))

if not l or len(l) < m:
    print()
ll = len(l)
lsum = [0] * (ll + 1)
for i in range(ll):
    lsum[i + 1] = lsum[i] + l[i]
dp = [999999999999] * (ll + 1)
dp[0] = 0
for j in range(m):
    for i in range(ll, 0, -1):
        for z in range(j - 1, i):
            dp[i] = min(dp[i], max(dp[z], lsum[i] - lsum[z]))
print(dp[ll])
